using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Hostal.Bussines.Entities;

namespace Hostal.Bussines.Repository.Mapping
{
    public class CheckOutMap : EntityTypeConfiguration<CheckOut>
    {
        public CheckOutMap()
        {
            // Primary Key
            this.HasKey(t => t.IdCheckOut);

            // Properties
            this.Property(t => t.IdCheckOut)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("CheckOut");
            this.Property(t => t.IdCheckOut).HasColumnName("IdCheckOut");
            this.Property(t => t.CheckIn_Id).HasColumnName("CheckIn_Id");
            this.Property(t => t.Huesped_Id).HasColumnName("Huesped_Id");
            this.Property(t => t.FechaSalida).HasColumnName("FechaSalida");
            this.Property(t => t.TotalHabitaciones).HasColumnName("TotalHabitaciones");
            this.Property(t => t.Monto).HasColumnName("Monto");

            // Relationships
            this.HasRequired(t => t.CheckIn)
                .WithMany(t => t.CheckOuts)
                .HasForeignKey(d => d.CheckIn_Id);
            this.HasRequired(t => t.Huesped)
                .WithMany(t => t.CheckOuts)
                .HasForeignKey(d => d.Huesped_Id);
            this.HasRequired(t => t.Empleado)
                .WithMany(t => t.CheckOuts)
                .HasForeignKey(d => d.Huesped_Id);

        }
    }
}
